import json
import os

import allure

from api.login_api import login_api
from config import config
from config.config import super_user_username, super_user_password, super_user_domain


def read_json_data(filename):
    filepath = os.path.join(config.BASE_DIR, 'data', filename)
    with open(filepath, 'r', encoding='utf-8') as f:
        json_data = json.load(f)
        data_list = []
        for data in json_data:
            value = tuple(data.values())
            data_list.append(value)
    return data_list


@allure.step("Get active x-token")
def get_active_token():
    resp = login_api(super_user_username, super_user_password, super_user_domain)
    x_token = resp.headers["x-active-token"]
    return x_token


if __name__ == '__main__':
    print(read_json_data("login/data_login.json"))
